package com.su.lesson05;

import javafx.scene.control.RadioButton;

import javax.swing.*;
import java.awt.*;

public class JButtonDemo02 extends JFrame {
    public JButtonDemo02() {
        Container container = getContentPane();
        container.setLayout(new GridLayout(3,1));
        //单选框
        JRadioButton button1 = new JRadioButton("Button 1");
        JRadioButton button2 = new JRadioButton("Button 2");
        JRadioButton button3 = new JRadioButton("Button 3");

        //由于单选框只能选择一个分组，一个组中只能选一个
        ButtonGroup group = new ButtonGroup();
        group.add(button1);
        group.add(button2);
        group.add(button3);

        container.add(button1, BorderLayout.NORTH);
        container.add(button2, BorderLayout.SOUTH);
        container.add(button3, BorderLayout.EAST);

        setVisible(true);
        setSize(300, 300);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    }

    public static void main(String[] args) {
        new JButtonDemo02();
    }
}
